package com.dc.seckill.service;

import com.dc.seckill.dao.UserDao;
import com.dc.seckill.domain.MiaoshaUser;
import com.dc.seckill.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserService {

	@Autowired
	UserDao userDao;
	
	public User getById(int id){
		return userDao.getById(id);
	}
	
	//(propagation=Propagation.SUPPORTS,rollbackFor=Exception.class)
	@Transactional
	public boolean saveUser(){
		User u1 = new User();
		u1.setId(2);
		u1.setName("戴建市");
		userDao.insert(u1);
		
		User u2 =  new User();
		u2.setId(1);
		u2.setName("haha");
		userDao.insert(u2);
		
		return true;
		
	}

	@Transactional
	public void saveUser(MiaoshaUser miaoshaUser){
		userDao.saveUser(miaoshaUser);
	}

}
